package com.sky.config;


import com.aliyun.dysmsapi20170525.Client;
import com.aliyun.teaopenapi.models.Config;
import com.sky.properties.AliyunProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Service;

import javax.websocket.server.ServerEndpoint;


@Configuration

public class AliyunSmsConfig {


    @Autowired
    private AliyunProperties aliyunProperties;

    @Bean(name = "aliyunSmsClient")
    public Client aliyunSmsClient() throws Exception {
        Config config = new Config()
                .setAccessKeyId(aliyunProperties.getAccessKeyId())
                .setAccessKeySecret(aliyunProperties.getAccessKeySecret())
                .setEndpoint("dysmsapi.aliyuncs.com");
        return new Client(config);
    }
}
